#ifndef FORMATTED_IO_H
#define FORMATTED_IO_H

typedef char (*receive_fun_ptr)();
typedef void (*send_fun_ptr)(char c);
typedef int (*avail_fun_ptr)();

class formatted_io
{
protected:
  send_fun_ptr send;
  receive_fun_ptr receive;
  avail_fun_ptr char_avail_fun;

public:
  formatted_io(send_fun_ptr sendi, receive_fun_ptr receivei, avail_fun_ptr char_availi)
    : send(sendi), receive(receivei), char_avail_fun(char_availi)
  { }

  void print(char c);
  void print(const char* s);
  void print(int i, unsigned base = 10);
  void print(unsigned i, unsigned base = 10);
  void print(float f, unsigned places = 6);
  void printf(const char * fmt, ...);
  char read_char();
  bool char_avail();
  int read_int();
};

#endif
